/**
 * @author LKQ
 * @date 2021/12/21 10:05
 * @description
 */
public class Solution {
    public static void main(String[] args) {
        Solution solution = new Solution();
        System.out.println(solution.numWaterBottles(2, 3));
    }

    public int numWaterBottles(int numBottles, int numExchange) {
        int ans = numBottles;
        while(numBottles >= numExchange) {
            int l = numBottles / numExchange, r = numBottles % numExchange;
            ans += l;
            numBottles = l + r;
        }
        return ans;
    }
}
